'use strict';
/**
 * 路由配置
 */
angular.module('app')
    .run(
        ['$rootScope', '$state', '$stateParams',
            function ($rootScope, $state, $stateParams) {
                $rootScope.$state = $state;
                $rootScope.$stateParams = $stateParams;
            }
        ]
    )
    .config(
        ['$stateProvider', '$urlRouterProvider',
            function ($stateProvider, $urlRouterProvider) {
                $urlRouterProvider.otherwise('/app/home');
                $stateProvider
                    .state('app', {
                        abstract: true,
                        url: '/app',
                        templateUrl: 'tpl/app.html'/*,
                         resolve: {
                         deps: ['uiLoad',
                         function (uiLoad) {
                         return uiLoad.load([
                         'vendor/plugins/layer/layer.js'
                         ]);
                         }]
                         }*/
                    })
                    .state('app.home', {
                        url: '/home',
                        templateUrl: 'tpl/app_dashboard_v1.html'
                    })
                    .state('app.system', {
                        url: '',
                        template: '<div ui-view></div>',
                         resolve: {
                         deps: ['uiLoad',
                         function (uiLoad) {
                         return uiLoad.load([
                             'js/plugin/tooltip.js'
                         ]);
                         }]
                         }
                    })
                    .state('app.system.dbprofilelist', {
                        url: '/dbprofilelist',
                        templateUrl: "views/dbprofile/dbprofileList.html",
                        controller: "DbprofileListCtrl",
                        controllerAs: 'vm',
                        resolve: {
                            deps: ['uiLoad',
                                function (uiLoad) {
                                    return uiLoad.load(['views/dbprofile/dbprofileList.controller.js']);
                                }]
                        }
                    })
                    .state('app.system.generatorWizard', {
                        url: '/generatorWizard',
                        templateUrl: "views/generator/generatorWizard.html",
                        controller: "GeneratorWizardCtrl",
                        controllerAs: 'vm',
                        resolve: {
                            deps: ['uiLoad',
                                function (uiLoad) {
                                    return uiLoad.load(['views/generator/generatorWizard.controller.js']);
                                }]
                        }
                    })
                    .state('app.system.templateList', {
                        url: '/templateList',
                        templateUrl: "views/template/templateList.html",
                        controller: "TemplateListCtrl",
                        controllerAs: 'vm',
                        resolve: {
                            deps: ['uiLoad',
                                function (uiLoad) {
                                    return uiLoad.load(['views/template/templateList.controller.js']);
                                }]
                        }
                    })
                    .state('app.system.fileInfoList', {
                        url: '/fileInfoList',
                        templateUrl: "views/fileInfo/fileInfoList.html",
                        controller: "FileInfoListCtrl",
                        controllerAs: 'vm',
                        resolve: {
                            deps: ['uiLoad',
                                function (uiLoad) {
                                    return uiLoad.load(['views/fileInfo/fileInfoList.controller.js']);
                                }]
                        }
                    })
                    .state('app.system.userList', {
                        url: '/userList',
                        templateUrl: "views/user/userList.html",
                        controller: "UserListCtrl",
                        controllerAs: 'vm',
                        resolve: {
                            deps: ['uiLoad',
                                function (uiLoad) {
                                    return uiLoad.load(['views/user/userList.controller.js']);
                                }]
                        }
                    })
                    .state('app.system.productList', {
                        url: '/productList',
                        templateUrl: "views/product/productList.html",
                        controller: "ProductListCtrl",
                        controllerAs: 'vm',
                        resolve: {
                            deps: ['uiLoad',
                                function (uiLoad) {
                                    return uiLoad.load(['views/product/productList.controller.js']);
                                }]
                        }
                    })
                    .state('app.system.order', {
                        url: '/order',
                        templateUrl: "views/order/orderDetail.html",
                        controller: "OrderCtrl",
                        controllerAs: 'vm',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function ($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function () {
                                            return $ocLazyLoad.load('views/order/order.controller.js');
                                        }
                                    );
                                }]
                        }
                    })
                ;
            }
        ]
    );